package control;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import view.MainF;

public class MouseListenerStatsPanel implements MouseListener{
	MainF mainF;
	public MouseListenerStatsPanel(MainF mainF){
		this.mainF = mainF;
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		
		int x1 = mainF.getCenter().getCenterStatsPanel().getX1();
		int x2 = mainF.getCenter().getCenterStatsPanel().getX2();
		
		int y1= mainF.getCenter().getCenterStatsPanel().getY1();
		int y2= mainF.getCenter().getCenterStatsPanel().getY2();
		
		int w1 = mainF.getCenter().getCenterStatsPanel().getW1();
		int w2 = mainF.getCenter().getCenterStatsPanel().getW2();
		
		int h1 = mainF.getCenter().getCenterStatsPanel().getH1();
		int h2 = mainF.getCenter().getCenterStatsPanel().getH2();
		
		//if(mainF.getCenter().getCenterStatsPanel().getChckbxleftGraf().isSelected() && mainF.getCenter().getCenterStatsPanel().getChckbxRightGraf().isSelected()){
		
		if (e.getX() >= x1 && e.getX() <= (x1+w1) && e.getY() >= y1 && e.getY() <= y1+h1) {	
		mainF.getCenter().getCenterStatsPanel().setLeftLocked(!mainF.getCenter().getCenterStatsPanel().isLeftLocked());
		mainF.getCenter().getCenterStatsPanel().setLockedLeftMX(e.getX());
		mainF.getCenter().getCenterStatsPanel().setLockedLeftMY(e.getY());
		}
		
		if (e.getX() >= x2 && e.getX() <= (x2+w2) && e.getY() >= y2 && e.getY() <= y2+h2) {	
			mainF.getCenter().getCenterStatsPanel().setRightLocked(!mainF.getCenter().getCenterStatsPanel().isRightLocked());
			mainF.getCenter().getCenterStatsPanel().setLockedRightMX(e.getX());
			mainF.getCenter().getCenterStatsPanel().setLockedRightMY(e.getY());
			}
		//}
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
